/**
 * 
 */
package playGround.border;


import static org.junit.Assert.assertEquals;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import playGround.dungeon.Direction;
import playGround.square.OrdinarySquare;
import playGround.square.Scale;
import playGround.square.Square;


/**
 * @author Niels Claeys, Maarten Christiaen
 *
 */
public class BorderTest {
	
	private Border wall;
	private Border door;
	private Square square;
	private Square square1;
	private Map <Direction,Border> borders;
	/**
	 * @throws java.lang.Exception
	 */
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		wall = new Wall(true);
		door = new Door();
		borders = new HashMap<Direction, Border>();
		borders.put(Direction.FLOOR,wall);
		borders.put(Direction.EAST, door);
		square = new OrdinarySquare(276,new BigDecimal(30), Scale.CELCIUS, borders);
		square1 = new OrdinarySquare(-30,new BigDecimal(80), Scale.CELCIUS, borders);
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}
	@Test (expected = IllegalArgumentException.class)
	public void addSquareFailTest(){
		Border wall1 = new Wall(true);
		wall1.addSquare(square);
	}
	@Test(expected= NullPointerException.class)
	public void addSquareNullTest(){
		wall.addSquare(null);
	}
	@Test(expected=IllegalArgumentException.class)
	public void addSquareToManySquaresTest(){
		wall.addSquare(square1);
		Map<Direction,Border> borders1 = new HashMap<Direction, Border>();
		borders1.put(Direction.EAST,door);
		Square square2 = new OrdinarySquare(276,new BigDecimal(30), Scale.CELCIUS, borders1);
		wall.addSquare(square2);
	}
	@Test(expected=IllegalArgumentException.class)
	public void addSquare2TimesSameSquareTest(){
		wall.addSquare(square);
	}
	@Test(expected = IndexOutOfBoundsException.class)
	public void getSquareAtToLargeIndex(){
		wall.getSquareAt(2);
	}
	@Test
	public void getSquareAtTest(){
		assertEquals(square,wall.getSquareAt(0));
	}
	@Test
	public void removeSquareTest(){
		wall.removeSquare(square);
		assertEquals(false,wall.containsSquare(square));
	}
	@Test(expected= IllegalArgumentException.class)
	public void removeSquareFailTest(){
		wall.removeSquare(null);
	}

}
